// run: $exec < input
#include <iostream>

int da[501][501];
enum  Choice { rightTowards, rightUp, down, leftDown };

void zigzagScan(int n)
{
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			std::cin >> da[i][j];
	int row = 0, col = 0;
	Choice choice = rightTowards;

	while (row != n - 1 || col != n - 1)
	{
		std::cout << da[row][col] << ' ';
		switch (choice)
		{
			case rightTowards:
				col++;
				if (row == 0)
					choice = leftDown;
				else
					choice = rightUp;
				break;
			case rightUp:
				row--;
				col++;
				if (row == 0 && col != n - 1)
					choice = rightTowards;
				else if (col == n - 1)
					choice = down;
				else
					choice = rightUp;
				break;
			case down:
				row++;
				if (col == 0)
					choice = rightUp;
				else
					choice = leftDown;
				break;
			case leftDown:
				row++;
				col--;
				if (col == 0 && row != n - 1)
					choice = down;
				else if (row == n - 1)
					choice = rightTowards;
				else
					choice = leftDown;
				break;
		}
	}
	std::cout << da[n - 1][n - 1] << ' ';
	std::cout << "\n";
}

int main()
{
	for (int n; std::cin >> n; ) zigzagScan(n);
}

